import com.Component.BeanLifeComponent;
import com.Controller.BeanScopesController;
import com.Controller.BeanScopesController2;
import com.Controller.UserController;

import com.Controller.UserController2;
import com.Service.User;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: ling
 * Date: 2022-11-12
 * Time: 16:10
 */
public class App {
    public static void main(String[] args) {
//        ApplicationContext context = new ClassPathXmlApplicationContext("spring-config.xml");
//        BeanScopesController beanScopesController = context.getBean("beanScopesController", BeanScopesController.class);
//        User user = beanScopesController.getUser();
//        System.out.println("A修改后的数据"+user);
//        BeanScopesController2 beanScopesController2 = context.getBean("beanScopesController2",BeanScopesController2.class);
//        User user1 = beanScopesController2.getUser();
//        System.out.println("B获取到的数据"+user1);
//        UserController user = context.getBean("userController",UserController.class);
//        user.doUserController();
//        UserController2 user2 = context.getBean("userController2",UserController2.class);
//        user2.doUserController2();
        ClassPathXmlApplicationContext context1 = new ClassPathXmlApplicationContext("spring-config.xml");//使用ApplicationContext的子类ClassPathXmlApplicationContext，因为ApplicationContext没有destroy方法
        BeanLifeComponent beanLifeComponent = context1.getBean("beanLife",BeanLifeComponent.class);
        beanLifeComponent.use();
        context1.destroy();
    }
}
